#ifndef Memory_h
#define Memory_h

#include <vector>
#include <list>
#include "resource.h"
#include <iostream>

using namespace std;

#define KERNEL 0
#define USER 1

using std::vector;
using std::list;

typedef vector<Page> PAGES;

class PageReplacementManager;

class Memory {	
public:
	Memory(const int pageSize, const int userPages, int kernelPages, bool disk);
	~Memory();
	int allocate(int place, int id, int pid);
	void free(int index, int place);
	byte* read(int place, int page, int offset, int pTime);
	void write(int place, int page, int offset, const byte* data, int ammount, int pTime);
	void replace(int place, int page, Page* what);
	PAGES* m_pages;

	void setPRM(PageReplacementManager* PRM);

	void printUser();
	void printKernel();
private:
	PageReplacementManager* m_PRM;
	int m_PageSize;
	list<int>* m_availablePages;
	int m_UserPages;
	int m_KernelPages;

	bool isDisk;
};

#endif
